
/* GENERATED CODE:
 *  Any modifications you make are guaranteed
 *  to be deleted when this is regenerated.
 * Please edit "PROTOCOLS" inside this directory
 *
 * Names are all upper case because of "String" and "string."
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OWED.Network.Messages.General;
using OWED.Network.Messages;
using OWED.Network.Messages.Reply;


namespace OWED.Network.Messages.Reply
{
	public class DiscussionsReply: IProtocolItem 
	{
		List <Discussion> my_Discussions;
		public DiscussionsReply (List <Discussion> Discussions)
		{
			my_Discussions = Discussions;
		}
		public List <Discussion> Discussions { get { return my_Discussions; } }


		public static new DiscussionsReply FromXml(XmlDocument xml)
		{
			XmlDocument doc;
			if (xml.SelectSingleNode("DiscussionsReply/Discussion") != null) {
				XmlNodeList list_Discussions = xml.SelectNodes("DiscussionsReply/Discussion");
				List <Discussion> Discussions = new List <Discussion>();
				foreach (XmlNode node in list_Discussions) {
					doc = new XmlDocument();
					doc.AppendChild(doc.ImportNode(node, true));
					Discussions.Add(Discussion.FromXml(doc));
				}

				return new DiscussionsReply(Discussions);
			}
			throw new ConnectionException("Bad document supposedly of type:DiscussionsReply");
		}


		public override XmlDocument ToXml()		{
			XmlDocument doc = new XmlDocument();

			doc.AppendChild(doc.CreateElement("DiscussionsReply"));

			if (my_Discussions != null) {
				XmlNode node;
				foreach (Discussion item in my_Discussions) {
					node = doc.ImportNode(item.ToXml().FirstChild, true);
					doc.FirstChild.AppendChild(node);
				}
			}

			return doc;
		}
	}
}
